#ifndef CL_RSS_Quelle_H_INCLUDED
#define CL_RSS_Quelle_H_INCLUDED


#include "CL_News.h"
#include<set>
#include<map>
#include<string>

// TODO (markus#1#): CL_RSS_Quelle.h: Copy Constructor and copy assignment

//throughout I assume the URLs and Header data characters are US-ASCII
class CL_RSS_Quelle
{
public:
    CL_RSS_Quelle(const std::string& u);
    CL_RSS_Quelle();
    void set_url(const std::string& s);
    CL_RSS_Quelle& operator=(const CL_RSS_Quelle& q);
    ~CL_RSS_Quelle();
    int add_news(newsmap&);
    operator bool() const;
    friend std::map<std::size_t,CL_News> operator+(newsmap&, CL_RSS_Quelle&);
    struct QError
    {
        std::string ErrorDescription;
        QError();
        QError(const std::string&);
        void set_error(const std::string& s){ErrorDescription=s;};
    };
private:
    time_t last_connection;
    std::size_t last_feed_hash;
    std::set<std::size_t>* last_news_hash;
    std::string url;
    bool is_erroneous;
    QError last_error;

    std::string& get_response_utf8(std::string& body);
    int create_news_from_xml(std::string&, newsmap&);

};

std::map<std::size_t,CL_News> operator+=(newsmap& m, CL_RSS_Quelle& q);

#endif // CL_RSS_Quelle_H_INCLUDED
